//
//  RNOLMeCardView.m
//  RongNiuOnline
//
//  Created by 王贵彬 on 2018/4/26.
//  Copyright © 2018年 rongniu. All rights reserved.
//

#import "RNOLMeCardView.h"

@interface RNOLMeCardView ()
@property (weak, nonatomic) IBOutlet UIView *topBg;
@property (weak, nonatomic) IBOutlet UIView *buttonBg;
//眼睛
@property (weak, nonatomic) IBOutlet UIButton *eyesButton;

//可用余额
@property (weak, nonatomic) IBOutlet UICountingLabel *availableBalanceLabel;
//累计收益
@property (weak, nonatomic) IBOutlet UICountingLabel *accumulatedIncomeLabel;

@property (weak, nonatomic) IBOutlet UICountingLabel *balanceLabel;
@end

@implementation RNOLMeCardView

- (void)awakeFromNib{
	[super awakeFromNib];
	[self setLayerShadow: KBlackColor offset:CGSizeMake(1, 1) radius: 5];
	self.topBg.layer.cornerRadius = 5;
	self.buttonBg.layer.cornerRadius = 5;
	self.layer.cornerRadius = 5;
    
}

- (void)willMoveToSuperview:(UIView *)newSuperview{
    [super willMoveToSuperview:newSuperview];
    [self skipNumberAnimation];

}

//数字跳动的动画
- (void)skipNumberAnimation{
    [self.availableBalanceLabel setFormat:@"%.2f"];
    [self.accumulatedIncomeLabel setFormat:@"%.2f"];
    [self.balanceLabel setFormat:@"%.2f"];
    
    [self.availableBalanceLabel countFromZeroTo: 10 withDuration: 0.5];
    [self.accumulatedIncomeLabel countFromZeroTo: 10 withDuration: 0.5];
    [self.balanceLabel countFromZeroTo: 5201314.00 withDuration: 0.5];
}

//睁眼/闭眼
- (IBAction)openCloseEyesAction:(UIButton *)sender {
    sender.selected = !sender.selected;
    [self setDisplayModeWithStatus: sender.selected];
}

//显示与否
- (void)setDisplayModeWithStatus:(BOOL)isCloseEyes{
    if (isCloseEyes) {
        self.availableBalanceLabel.text = @"****";
        self.accumulatedIncomeLabel.text = @"****";
        self.balanceLabel.text = @"恭喜发财🎉~";
    }else{
        [self skipNumberAnimation];
        self.availableBalanceLabel.text = @"¥666.00";
        self.accumulatedIncomeLabel.text = @"¥233.00";
        self.balanceLabel.text = @"¥5201314.00";
    }
}


//充值
- (IBAction)rechargeAction:(UIButton *)sender {
	!self.rechargeBlock? : self.rechargeBlock();
}

	//提现
- (IBAction)withdrawAction:(UIButton *)sender {
	!self.withdrawBlock? : self.withdrawBlock();
}

@end
